from datetime import datetime
import nonebot
import pytz
from aiocqhttp.exceptions import Error as CQHttpError
#第一节课
@nonebot.scheduler.scheduled_job('cron', hour = '07',minute ='45' ,second = '00')
async def _():
    bot = nonebot.get_bot()
    try:
        f=open("C:\\awesome-bot\\awesome\\plugins\\QQ.txt")
        list=f.read()
        f.close
        list=eval(list)
        for user_id in list:
            s=open('c:\\awesome-bot\\awesome\\plugins\\course\\'+str(user_id)+'.txt',encoding='utf-8')
            kb =eval(s.read())
            now = datetime.now().strftime('%Y-%m-%d')  # 获取当前日期
            now = now.replace('-', '')
            if now not in kb.keys():
                pass
            else:
                ulist = kb[now]
                for s in ulist:
                    if s[0:5]=='08:00':
                         s=str(s).split()
                         await bot.send_private_msg(user_id=user_id, message="宝贝，上课啦！\n课程："+str(s[1])+'\n'+"地点："+str(s[2])+'\n'+"老师："+str(s[3]))
    except CQHttpError:
        pass

#第二节课
@nonebot.scheduler.scheduled_job('cron', hour = '09',minute ='55' ,second = '00')
async def _():
    bot = nonebot.get_bot()
    try:
        f=open("C:\\awesome-bot\\awesome\\plugins\\QQ.txt")
        list=f.read()
        f.close
        list=eval(list)
        for user_id in list:
            s=open('c:\\awesome-bot\\awesome\\plugins\\course\\'+str(user_id)+'.txt',encoding='utf-8')
            kb =eval(s.read())
            now = datetime.now().strftime('%Y-%m-%d')  # 获取当前日期
            now = now.replace('-', '')
            if now not in kb.keys():
                pass
            else:
                ulist = kb[now]
                for s in ulist:
                    if s[0:5]=='10:10':
                         s=str(s).split()
                         await bot.send_private_msg(user_id=user_id, message="宝贝，上课啦！\n课程："+str(s[1])+'\n'+"地点："+str(s[2])+'\n'+"老师："+str(s[3]))
    except CQHttpError:
        pass
#第三节课
@nonebot.scheduler.scheduled_job('cron', hour = '13',minute ='45' ,second = '00')
async def _():
    bot = nonebot.get_bot()
    try:
        f=open("C:\\awesome-bot\\awesome\\plugins\\QQ.txt")
        list=f.read()
        f.close
        list=eval(list)
        for user_id in list:
            s=open('c:\\awesome-bot\\awesome\\plugins\\course\\'+str(user_id)+'.txt',encoding='utf-8')
            kb =eval(s.read())
            now = datetime.now().strftime('%Y-%m-%d')  # 获取当前日期
            now = now.replace('-', '')
            if now not in kb.keys():
                pass
            else:
                ulist = kb[now]
                for s in ulist:
                    if s[0:5]=='14:00':
                         s=str(s).split()
                         await bot.send_private_msg(user_id=user_id, message="宝贝，上课啦！\n课程："+str(s[1])+'\n'+"地点："+str(s[2])+'\n'+"老师："+str(s[3]))
    except CQHttpError:
        pass
#第四节课
@nonebot.scheduler.scheduled_job('cron', hour = '15',minute ='55' ,second = '00')
async def _():
    bot = nonebot.get_bot()
    try:
        f=open("C:\\awesome-bot\\awesome\\plugins\\QQ.txt")
        list=f.read()
        f.close
        list=eval(list)
        for user_id in list:
            s=open('c:\\awesome-bot\\awesome\\plugins\\course\\'+str(user_id)+'.txt',encoding='utf-8')
            kb =eval(s.read())
            now = datetime.now().strftime('%Y-%m-%d')  # 获取当前日期
            now = now.replace('-', '')
            if now not in kb.keys():
                pass
            else:
                ulist = kb[now]
                for s in ulist:
                    if s[0:5]=='16:10':
                         s=str(s).split()
                         await bot.send_private_msg(user_id=user_id, message="宝贝，上课啦！\n课程："+str(s[1])+'\n'+"地点："+str(s[2])+'\n'+"老师："+str(s[3]))
    except CQHttpError:
        pass
#第五节课
@nonebot.scheduler.scheduled_job('cron', hour = '18',minute ='45' ,second = '00')
async def _():
    bot = nonebot.get_bot()
    try:
        f=open("C:\\awesome-bot\\awesome\\plugins\\QQ.txt")
        list=f.read()
        f.close
        list=eval(list)
        for user_id in list:
            s=open('c:\\awesome-bot\\awesome\\plugins\\course\\'+str(user_id)+'.txt',encoding='utf-8')
            kb =eval(s.read())
            now = datetime.now().strftime('%Y-%m-%d')  # 获取当前日期
            now = now.replace('-', '')
            if now not in kb.keys():
                pass
            else:
                ulist = kb[now]
                for s in ulist:
                    if s[0:5]=='19:00':
                         s=str(s).split()
                         await bot.send_private_msg(user_id=user_id, message="宝贝，上课啦！\n课程："+str(s[1])+'\n'+"地点："+str(s[2])+'\n'+"老师："+str(s[3]))
    except CQHttpError:
        pass
